import $util from './util.js'
const UserCenter = {
    isLogin(){
    let user = this.getUserInfo();
    return user ?true:false;
    },
	isLogintrue(){
	let user = this.getUserInfo();
	return user && user.register && (user.register ==1 || user.register =='1') ?true:false;
	},
    setUserInfo(userInfo){
	uni.setStorageSync('userInfo', JSON.stringify(userInfo));
	$util.sendEvent('setUserInfo',userInfo);
	// 触发登录成功事件
	$util.sendEvent('loginSuccess');
    },
    getUserInfo(){
        let user = uni.getStorageSync('userInfo');
        return user && user != '' && user != 'undefined' && user != undefined  ? JSON.parse(user):false;
    }
};

export default UserCenter;